package com.moly.thrift.person;

import org.apache.thrift.server.TServer;
import org.apache.thrift.server.TSimpleServer;
import org.apache.thrift.transport.TServerSocket;
import org.apache.thrift.transport.TServerTransport;
import org.apache.thrift.transport.TTransportException;

public class PersonServer {


    public static void main(String[] args) {

        PersonService.Processor processor = new PersonService.Processor(new PersonServiceHandler());
        PersonRunnable personRunnable = new PersonRunnable(processor);

        new Thread(personRunnable).start();

    }


}

class PersonRunnable implements Runnable {

    PersonService.Processor processor;
    PersonRunnable(PersonService.Processor processor) {
        this.processor = processor;

    }
            @Override
    public void run() {
        TServerTransport serverTransport = null;
        try {
            serverTransport = new TServerSocket(9090);
            TServer server = new TSimpleServer(new TServer.Args(serverTransport).processor(processor));

            System.out.println("服务器启动了");
            server.serve();
        } catch (TTransportException e) {
            e.printStackTrace();
        }finally {
        }

    }
}